<?php
class SearchModel extends Model {
	public function getuser($nickname,$dep,$p,$status = 1){
		$user = D('UserView');
		$str=D('Structure');
		
		$where['status']=$status;
		if($nickname){
			$where['nickname'] = array('like','%'.$nickname.'%');
		}
		if($dep){
			$where['department_id']=$dep;
		}
		
		import('@.ORG.Page');
		$count = $user->where($where)->count();
		$Page = new Page($count,15);
		$Page->parameter = 'status='.$status.'&dep='.$dep;
		$show  = $Page->show();
		$userlist = $user->where($where)->page($p.',15')->order('reg_time desc')->select();
		
		$verify=D('Verify');
		$str=D('Structure');
		//查上级
		foreach($userlist as $k=>$vo){
			$gid[$k]['dep']=$str->getTopposition($userlist[$k]['department_id']);
			foreach($gid[$k]['dep']['id'] as $key=>$vv){
				$dname[$key]=$str->getDename($vv);
				$userlist[$k]['dep'] .= ' - '.$dname[$key];
			}
			$userlist[$k]['dep'] = substr($userlist[$k]['dep'], 2);
			$userlist[$k]['v_status'] =$verify->getV($userlist[$k]['verify_id']);
		}
		
//		dump($where);
		return array('page'=>$show ,'userlist'=>$userlist);
	}
}
?>